package ControlLayer;
import ModelLayer.*;

  
import java.util.ArrayList;
//model layer package has to be imported
/**
 * 
 * @Author (Alexander Hvidberg, Dennis Kirkebak & Thomas Kulmbach)
 * @Team (Group 1)
 * @Version (08/11/13)
 * 
 */
public class DVDCtr
{
    //declare instance variables to reference containers
    //passed as arguments from the main class
    private static DVDCtr instance;
    private DVDContainer dvdContainer;

    /**
     * Constructor for objects of class DVDCtr
     */
    private DVDCtr()//DVD container is to be passed as parameter from the main controller
    {
        //set up references to containers
        dvdContainer = DVDContainer.getInstance();
    }
    
    public static DVDCtr getInstance() {
        if(instance == null) {
            instance = new DVDCtr();
        }
        return instance;
    }
    
    //Dummy implementation: after implementing the model layer 
    //objects of class DVD are to be returned, not String
    public void findDVD(int id)
    {
        //this method is to search the container for a DVD
        //with an id-number equal to the parameter no
        //when the dvd is found, the method is to call print-methods in the TUI layer
        DVD d = dvdContainer.findDVD(id);
        if(d!=null) {
            d.printDVDInfo();
        }
        else {
            System.out.println("\f  There is no DVD with this ID. \n ");
        }
       
    }

    public void findDVDAll(int id)
    {
        //this method is to search the container for a DVD
        //with an id-number equal to the parameter no
        //when the dvd is found, the method is to call print-methods in the TUI layer
        DVD d = dvdContainer.findDVD(id);
        if(d!=null) {
            d.printAllDVDInfo();
        }
        else {
            System.out.println("\f  There is no DVD with this ID. \n ");
        }
       
    }
    
    /**
     * Prints out a list of articles of this DVD
     */
    public void printArticles(int id)
    {
        dvdContainer.printArticles(id);
    }
    
    /**
     * Deletes an article on the chosen dvd
     */
    public void deleteCopy(int id, int serialNumber)
    {
        dvdContainer.deleteDVDArticle(id, serialNumber);
    }
    
    public DVD returnDVD(int id){
        return dvdContainer.findDVD(id);
    }
    //Dummy implementation: more parameters are probaly to added
    public void createDVD(String title, String artist, String releaseDate, String aqDate, double aqPrice)
    {
        dvdContainer.createDVD(title, artist, releaseDate, aqDate, aqPrice); 
    }
    
    public void deleteDVD(int id)
    {
        dvdContainer.deleteDVD(id);       
    }
    
    public void createCopy(int id, String aqDate, double aqPrice)
    {
        dvdContainer.createDVDArticle(id, aqDate, aqPrice);
    }
    
    public void printDVDList()
    {
        dvdContainer.printDVDList();
    }
    
    public ArrayList listAllDvds()
    {
          return dvdContainer.getDVDList();
    }
}
